<script>

import * as echarts from 'echarts';
export default {
  name: 'VisualizationSeven',
  data() {
    return{

    }
  },
  mounted() {
    this.getData();
  },
  methods:{open1(msg) {
      this.$notify({
        title: msg,
        message: '这是一条成功的提示消息',
        type: 'success'
      });
    },
    open2(msg) {
      this.$notify({
        title: msg,
        message: '这是一条警告的提示消息',
        type: 'warning'
      });
    },
    open4(msg) {
      this.$notify.error({
        title: msg,
        message: '这是一条错误的提示消息'
      });
    },
    getData(){
      this.$axios.get('/api/vis/getData8', {

      }).then(res =>{

        if (res.data.code === 20041) {
          let data = [];
          for (let i = 0; i < res.data.data.length; i++) {
            data.push(
                { value: res.data.data[i]["param1"], name: res.data.data[i]["param"] },
            );
          }
          this.init(data);
        }

      }).catch(error =>{
        error = "系统出错了"
        this.open4(error)
      })
    },
    init(data) {

      var chartDom = document.getElementById('main-box7');
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        // legend: {
        //   top: 'bottom'
        // },
        title: [
          {
            text: '房屋维护时间'
          }
        ],
        toolbox: {
          show: true,
          feature: {
            mark: { show: true },
            dataView: { show: true, readOnly: false },
            restore: { show: true },
            saveAsImage: { show: true }
          }
        },
        series: [
          {
            name: 'Nightingale Chart',
            type: 'pie',
            radius: [50, 250],
            center: ['50%', '50%'],
            roseType: 'area',
            itemStyle: {
              borderRadius: 8
            },
            data: data
          }
        ]
      };

      option && myChart.setOption(option);

    }
  }
}

</script>

<template>
  <div id="main-box7"></div>
</template>

<style scoped>
#main-box7 {
  height: 100%;
  width: 100%;
}
</style>